package day4.liberary.operator;

import day4.liberary.book1.booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: watermelon
 * Date: 2025-05-30
 * Time: 23:02
 */
public class deletebook implements Job{
    @Override
    public void working(booklist list) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入要删除的书名:");
        String bookname=scanner.next();
        for (int i = 0; i < list.capacity; i++) {
            if(list.booklist[i].getName().equals(bookname))
            {
                for (int j = i; j < list.capacity; j++) {
                    list.booklist[j]=list.booklist[j+1];
                }
                break;
            }
            if (i==list.capacity-1)
            {
                System.out.println("没有该书名");
            }
        }
        list.capacity--;
    }
}
